# 限制版本号
cmake_minimum_required(VERSION 3.10)
#设定工程名
PROJECT(TopProject)

# 设置C++标准（重要！）
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 关键修改：设置用户级安装前缀
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
    set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/dist" CACHE PATH "Install path" FORCE)
endif()


# 设置库的版本
if(${CMAKE_BUILD_TYPE} MATCHES "Release")
    SET(CMAKE_BUILD_TYPE "Releaese")
    MESSAGE(STATUS "Release版本")
else()
    SET(CMAKE_BUILD_TYPE "Debug")
    MESSAGE(STATUS "Debug版本")
endif()

#设置输出目录/动态库目录/静态库目录 
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

# 添加子目录源代码
add_subdirectory(src)

#添加库目录源代码
add_subdirectory(libs)